<template>
  <div>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  <el-form-item label="名称" prop="name">
    <el-input v-model="ruleForm.name"></el-input>
  </el-form-item>



  <el-form-item label="选择类别" prop="type">
    <el-checkbox-group v-model="ruleForm.type">
      <el-checkbox label="全部" name="type"></el-checkbox>
      <el-checkbox label="免费" name="type"></el-checkbox>
      <el-checkbox label="限免" name="type"></el-checkbox>
      <el-checkbox label="会员" name="type"></el-checkbox>

    </el-checkbox-group>
  </el-form-item>

  <el-form-item label="选择标签" prop="resource">
    <el-radio-group v-model="ruleForm.resource">
      <el-radio label="全部"></el-radio>
      <el-radio label="Python"></el-radio>
      <el-radio label="C/C++"></el-radio>
      <el-radio label="Linux"></el-radio>
      <el-radio label="Web"></el-radio>
      <el-radio label="信息安全"></el-radio>
      <el-radio label="PHP"></el-radio>
      <el-radio label="NodeJS"></el-radio>
      <el-radio label="Android"></el-radio>
      <el-radio label="GO"></el-radio>
      <el-radio label="Spark"></el-radio>
      <el-radio label="计算机专业课"></el-radio>
      <el-radio label="Hadoop"></el-radio>
      <el-radio label="HTMLS"></el-radio>
      <el-radio label="Scala"></el-radio>
      <el-radio label="Ruby"></el-radio>
      <el-radio label="R"></el-radio>
      <el-radio label="网路"></el-radio>
      <el-radio label="Git"></el-radio>
      <el-radio label="SQL"></el-radio>
      <el-radio label="NoSQL"></el-radio>
      <el-radio label="算法"></el-radio>
      <el-radio label="Docker"></el-radio>
      <el-radio label="Swift"></el-radio>
      <el-radio label="汇编"></el-radio>
      <el-radio label="Windows"></el-radio>
    </el-radio-group>
  </el-form-item>

  <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </el-form-item>
</el-form>
<el-upload
  class="avatar-uploader"
  action="https://jsonplaceholder.typicode.com/posts/"
  :show-file-list="false"
  :on-success="handleAvatarSuccess"
  :before-upload="beforeAvatarUpload">
  <img v-if="imageUrl" :src="imageUrl" class="avatar">
  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
  </div>
</template>

<style>
 .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>

<script>
 export default {
    data() {
      return {
        ruleForm: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: '',
          imageUrl: '',
        },
        rules: {
          name: [
            { required: true, message: '请输入活动名称', trigger: 'blur' },
            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          ],
          region: [
            { required: true, message: '请选择活动区域', trigger: 'change' }
          ],
          date1: [
            { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
          ],
          date2: [
            { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
          ],
          type: [
            { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
          ],
          resource: [
            { required: true, message: '请选择活动资源', trigger: 'change' }
          ],
          desc: [
            { required: true, message: '请填写活动形式', trigger: 'blur' }
          ]
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>

